//
//  ViewController.m
//  SendEmailDemo
//
//  Created by luoruowen on 2016/10/10.
//  Copyright © 2016年 luoruowen. All rights reserved.
//

#import "ViewController.h"
#import "NISendMail.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitleView:@"邮件测试"];
    [self.view addSubview:self.layout];
    
    [self.layout addInterval:20];
    NIButton * sendEmail1=[[NIButton alloc]initWithFrame:CGRectMake(10, 0, NIVIEW_WIDTH-20, 40) text:@"使用MFMailComposeViewController发送邮件" plistStyleKey:@"PropertyCenter" block:^(id button) {
        
        NISendMailView * sm=[[NISendMailView alloc]initWithTitle:@"发送标题" contentStr:@"测试内容:使用MFMailComposeViewController发送邮件" toRecipients:@[@"732649784@qq.com"] ccRecipients:nil bccRecipients:nil attachmentsData:nil block:^(id result) {
            //发送取消,发送成功,发送失败,邮件被保存
            [NIPromptUtil showLong:[NSString stringWithFormat:@"%@",result]];
        }];
        if(sm){
            [self presentViewController:sm animated:YES completion:nil];
        }else{
            [NIPromptUtil showLong:[NSString stringWithFormat:@"%@",@"手机没有配置邮箱"]];
        }
        
    }];
    [self.layout addView:sendEmail1];
    
    [self.layout addInterval:20];
    NIButton * sendEmail2=[[NIButton alloc]initWithFrame:CGRectMake(10, 0, NIVIEW_WIDTH-20, 40) text:@"使用第三方库SKPSMTPMessage发送邮件" plistStyleKey:@"PropertyCenter" block:^(id button) {
        
        NISendMail * sm=[[NISendMail alloc]initWithEmail:@"写发送者邮箱" password:@"发送者密码,如果是qq邮箱要用独立密码" relayHost:@"smtp.qq.com"];
        [sm sendMail:@"标题" toEmail:@"732649784@qq.com" content:@"内容测试:使用第三方库SKPSMTPMessage发送邮件" enclosureName:nil enclosure:nil];
        
    }];
    [self.layout addView:sendEmail2];
    
    [self.layout reloadLayout];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
